package soundwave.com.demo.adpater;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.ArrayList;

import soundwave.com.demo.R;
import soundwave.com.demo.test.ViewpagerList_item_test;

/**
 * Created by xu on 2017/4/16.
 */

public class ViewpagerList_item_adapter extends ArrayAdapter<ViewpagerList_item_test> {
    private ArrayList<ViewpagerList_item_test>list;
    private int layoutid;
    private Context context;
    private LayoutInflater inflater=null;
    public ViewpagerList_item_adapter(Context context, int resource,ArrayList<ViewpagerList_item_test> list) {
        super(context, resource,list);
        this.list=list;
        this.layoutid=resource;
        this.context=context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @NonNull
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view=convertView;
        if (view==null){
            inflater=LayoutInflater.from(context);
            view=inflater.inflate(layoutid,null);
        }
        ViewpagerList_item_test viewpagerList_item_test=getItem(position);
        TextView item= (TextView) view.findViewById(R.id.item);
        item.setText(viewpagerList_item_test.getConntent());
        return view;
    }
}
